package com.yijinsuo.util;

import android.util.Log;

import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;

/**
 * Created by ekikousei易皇星 on 16/12/1.
 * E-mail:13764664731@163.com
 * Signature:缘分是本书,翻的不经意会错过,读的太认真会流泪!!
 * <p/>
 * TODO:类描述:
 */
public class GetUrlUtils {

    private static final String TAG = "getUrlUtils";

    public static String geturl(String url,  Map<String, String> params){
        StringBuilder buf = new StringBuilder(url);
        Set<Entry<String, String>> entrys = null;
        // 如果是GET请求，则请求参数在URL中
        if (params != null && !params.isEmpty()) {
            buf.append("?");
            entrys = params.entrySet();
            for (Map.Entry<String, String> entry : entrys) {
                try {
                    buf.append(entry.getKey()).append("=")
//                            .append(URLEncoder.encode(entry.getValue(), "UTF-8"))
                            .append(entry.getValue())
                            .append("&");
                } catch (Exception e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }
            }
            buf.deleteCharAt(buf.length() - 1);
        }

        String strurl = buf.toString();

        Log.i(TAG, "url:===  "+strurl);

        return strurl;

    }



}
